package cn.nuomi.shop.api.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @date: 2021/4/26 15:34
 * @description: 编码过滤器
 */
public class EncoderFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        //请求编码
        servletRequest.setCharacterEncoding("utf-8");
        //返回结果设置编码
        servletResponse.setContentType("text/html;charset=UTF-8");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
